-
Notifications
You must be signed in to change notification settings - Fork 0
Add Mii (gen2) class #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
DaniElectra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MiiGen2 name feels a little weird tbh. What about something like MiiV2?
Initially I did use I ended up stealing the "gen" naming scheme from https://github.com/HEYimHeroic/mii2studio I'm open to changing this though since I agree "gen2" sounds awkward |
|
I'm wondering if we should change how Maybe we should just store the original value instead? Or change to using a Date object for consistency/clarity? |
to be clear, i didn't actually make the filenames for those files - i always thought it was a poor choice. i would just go with the official internal name, ver3. i think Nintendo considers the DS format to be version/generation "2", and Wii to be 1, and for all other projects that's what i've been going by. Wii format, DS format, and the ver3 format (since it's used in so many different applications, a console name doesn't really fit). and then just "MiiStudio" or "charinfo" or "SwitchNAND" etc. for all the other format names... because there's like 5 different ones on the Switch alone, they don't really fit into a console name or a generation-type name this format type being ver3 instead of 2 is also likely connected to the fact that all ver3 Mii data files should start with 0x03. unless the Mii was made with the Wii U Mii Maker's camera look-alike feature (yet another genius calculated decision by Nintendo) |
|
Here's my thoughts. Truncating this huge comment. Accuracy suggestions
Here is the entire CFLiMiiDataPacket (Ver3StoreData, FFLStoreData...) struct I reconstructed from DWARF.typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef struct CFLiAuthorID
{
union
{
u8 data[8];
u16 value16[4];
};
}
CFLiAuthorID;
typedef struct CFLCreateID
{
union
{
u8 data[10];
u16 value16[5];
};
}
CFLCreateID;
typedef struct CFLiMiiDataPacket // CFLiPackedMiiDataCore + CFLiPackedMiiDataOfficial + CRC
{
u32 miiVersion : 8;
u32 copyable : 1;
u32 ngWord : 1;
u32 regionMove : 2;
u32 fontRegion : 2;
u32 reserved_0 : 2;
u32 roomIndex : 4;
u32 positionInRoom : 4;
u32 authorType : 4;
u32 birthPlatform : 3;
u32 reserved_1 : 1;
struct CFLiAuthorID authorID;
struct CFLCreateID createID;
u8 reserved_2[2];
u16 gender : 1;
u16 birthMonth : 4;
u16 birthDay : 5;
u16 favoriteColor : 4;
u16 favorite : 1;
u16 padding_0 : 1;
u16 name[10];
u8 height;
u8 build;
u16 localonly : 1;
u16 faceType : 4;
u16 faceColor : 3;
u16 faceTex : 4;
u16 faceMake : 4;
u16 hairType : 8;
u16 hairColor : 3;
u16 hairFlip : 1;
u16 padding_1 : 4;
u16 eyeType : 6;
u16 eyeColor : 3;
u16 eyeScale : 4;
u16 eyeAspect : 3;
u16 eyeRotate : 5;
u16 eyeX : 4;
u16 eyeY : 5;
u16 padding_2 : 2;
u16 eyebrowType : 5;
u16 eyebrowColor : 3;
u16 eyebrowScale : 4;
u16 eyebrowAspect : 3;
u16 padding_3 : 1;
u16 eyebrowRotate : 5;
u16 eyebrowX : 4;
u16 eyebrowY : 5;
u16 padding_4 : 2;
u16 noseType : 5;
u16 noseScale : 4;
u16 noseY : 5;
u16 padding_5 : 2;
u16 mouthType : 6;
u16 mouthColor : 3;
u16 mouthScale : 4;
u16 mouthAspect : 3;
u16 mouthY : 5;
u16 mustacheType : 3;
u16 padding_6 : 8;
u16 beardType : 3;
u16 beardColor : 3;
u16 beardScale : 4;
u16 beardY : 5;
u16 padding_7 : 1;
u16 glassType : 4;
u16 glassColor : 3;
u16 glassScale : 4;
u16 glassY : 5;
u16 moleType : 1;
u16 moleScale : 4;
u16 moleX : 5;
u16 moleY : 5;
// ^^ In CFLiPackedMiiDataOfficial, this is called "coredata"
u16 padding_8 : 1;
u16 creatorName[10];
// ^^ In CFLiPackedMiiDataPacket, this is called "rawdata"
u16 padding_9;
u16 crc;
}
CFLiMiiDataPacket;And here are getters for Ver3StoreDataRaw from nn::mii.enum nn::mii::detail::Ver3MiiVersion nn::mii::detail::Ver3StoreDataRaw::GetMiiVersion(void) const;
enum nn::mii::detail::Ver3Copyable nn::mii::detail::Ver3StoreDataRaw::GetCopyable(void) const;
enum nn::mii::detail::Ver3NgWord nn::mii::detail::Ver3StoreDataRaw::GetNgWord(void) const;
enum nn::mii::RegionMove nn::mii::detail::Ver3StoreDataRaw::GetRegionMove(void) const;
enum nn::mii::FontRegion nn::mii::detail::Ver3StoreDataRaw::GetFontRegion(void) const;
enum nn::mii::detail::Ver3RoomIndex nn::mii::detail::Ver3StoreDataRaw::GetRoomIndex(void) const;
enum nn::mii::detail::Ver3PositionInRoom nn::mii::detail::Ver3StoreDataRaw::GetPositionInRoom(void) const;
enum nn::mii::detail::Ver3AuthorType nn::mii::detail::Ver3StoreDataRaw::GetAuthorType(void) const;
enum nn::mii::detail::Ver3BirthPlatform nn::mii::detail::Ver3StoreDataRaw::GetBirthPlatform(void) const;
enum nn::mii::Gender nn::mii::detail::Ver3StoreDataRaw::GetGender(void) const;
enum nn::mii::detail::Ver3BirthMonth nn::mii::detail::Ver3StoreDataRaw::GetBirthMonth(void) const;
enum nn::mii::detail::Ver3BirthDay nn::mii::detail::Ver3StoreDataRaw::GetBirthDay(void) const;
enum nn::mii::FavoriteColor nn::mii::detail::Ver3StoreDataRaw::GetFavoriteColor(void) const;
enum nn::mii::detail::Ver3Favorite nn::mii::detail::Ver3StoreDataRaw::GetFavorite(void) const;
enum nn::mii::detail::Ver3MiiHeight nn::mii::detail::Ver3StoreDataRaw::GetHeight(void) const;
enum nn::mii::detail::Ver3MiiBuild nn::mii::detail::Ver3StoreDataRaw::GetBuild(void) const;
enum nn::mii::detail::Ver3LocalOnly nn::mii::detail::Ver3StoreDataRaw::GetLocalonly(void) const;
enum nn::mii::FacelineType nn::mii::detail::Ver3StoreDataRaw::GetFaceType(void) const;
enum nn::mii::detail::Ver3FacelineColor nn::mii::detail::Ver3StoreDataRaw::GetFaceColor(void) const;
enum nn::mii::FacelineWrinkle nn::mii::detail::Ver3StoreDataRaw::GetFaceTex(void) const;
enum nn::mii::FacelineMake nn::mii::detail::Ver3StoreDataRaw::GetFaceMake(void) const;
enum nn::mii::HairType nn::mii::detail::Ver3StoreDataRaw::GetHairType(void) const;
enum nn::mii::detail::Ver3HairColor nn::mii::detail::Ver3StoreDataRaw::GetHairColor(void) const;
enum nn::mii::HairFlip nn::mii::detail::Ver3StoreDataRaw::GetHairFlip(void) const;
enum nn::mii::EyeType nn::mii::detail::Ver3StoreDataRaw::GetEyeType(void) const;
enum nn::mii::detail::Ver3EyeColor nn::mii::detail::Ver3StoreDataRaw::GetEyeColor(void) const;
enum nn::mii::EyeScale nn::mii::detail::Ver3StoreDataRaw::GetEyeScale(void) const;
enum nn::mii::EyeAspect nn::mii::detail::Ver3StoreDataRaw::GetEyeAspect(void) const;
enum nn::mii::EyeRotate nn::mii::detail::Ver3StoreDataRaw::GetEyeRotate(void) const;
enum nn::mii::EyeX nn::mii::detail::Ver3StoreDataRaw::GetEyeX(void) const;
enum nn::mii::EyeY nn::mii::detail::Ver3StoreDataRaw::GetEyeY(void) const;
enum nn::mii::EyebrowType nn::mii::detail::Ver3StoreDataRaw::GetEyebrowType(void) const;
enum nn::mii::detail::Ver3HairColor nn::mii::detail::Ver3StoreDataRaw::GetEyebrowColor(void) const;
enum nn::mii::EyebrowScale nn::mii::detail::Ver3StoreDataRaw::GetEyebrowScale(void) const;
enum nn::mii::EyebrowAspect nn::mii::detail::Ver3StoreDataRaw::GetEyebrowAspect(void) const;
enum nn::mii::EyebrowRotate nn::mii::detail::Ver3StoreDataRaw::GetEyebrowRotate(void) const;
enum nn::mii::EyebrowX nn::mii::detail::Ver3StoreDataRaw::GetEyebrowX(void) const;
enum nn::mii::EyebrowY nn::mii::detail::Ver3StoreDataRaw::GetEyebrowY(void) const;
enum nn::mii::NoseType nn::mii::detail::Ver3StoreDataRaw::GetNoseType(void) const;
enum nn::mii::NoseScale nn::mii::detail::Ver3StoreDataRaw::GetNoseScale(void) const;
enum nn::mii::NoseY nn::mii::detail::Ver3StoreDataRaw::GetNoseY(void) const;
enum nn::mii::MouthType nn::mii::detail::Ver3StoreDataRaw::GetMouthType(void) const;
enum nn::mii::detail::Ver3MouthColor nn::mii::detail::Ver3StoreDataRaw::GetMouthColor(void) const;
enum nn::mii::MouthScale nn::mii::detail::Ver3StoreDataRaw::GetMouthScale(void) const;
enum nn::mii::MouthAspect nn::mii::detail::Ver3StoreDataRaw::GetMouthAspect(void) const;
enum nn::mii::MouthY nn::mii::detail::Ver3StoreDataRaw::GetMouthY(void) const;
enum nn::mii::MustacheType nn::mii::detail::Ver3StoreDataRaw::GetMustacheType(void) const;
enum nn::mii::BeardType nn::mii::detail::Ver3StoreDataRaw::GetBeardType(void) const;
enum nn::mii::detail::Ver3HairColor nn::mii::detail::Ver3StoreDataRaw::GetBeardColor(void) const;
enum nn::mii::MustacheScale nn::mii::detail::Ver3StoreDataRaw::GetBeardScale(void) const;
enum nn::mii::MustacheY nn::mii::detail::Ver3StoreDataRaw::GetBeardY(void) const;
enum nn::mii::detail::Ver3GlassType nn::mii::detail::Ver3StoreDataRaw::GetGlassType(void) const;
enum nn::mii::detail::Ver3GlassColor nn::mii::detail::Ver3StoreDataRaw::GetGlassColor(void) const;
enum nn::mii::GlassScale nn::mii::detail::Ver3StoreDataRaw::GetGlassScale(void) const;
enum nn::mii::GlassY nn::mii::detail::Ver3StoreDataRaw::GetGlassY(void) const;
enum nn::mii::MoleType nn::mii::detail::Ver3StoreDataRaw::GetMoleType(void) const;
enum nn::mii::MoleScale nn::mii::detail::Ver3StoreDataRaw::GetMoleScale(void) const;
enum nn::mii::MoleX nn::mii::detail::Ver3StoreDataRaw::GetMoleX(void) const;
enum nn::mii::MoleY nn::mii::detail::Ver3StoreDataRaw::GetMoleY(void) const;
void nn::mii::detail::Ver3StoreDataRaw::GetAuthorId(struct nn::mii::detail::Ver3AuthorId *) const;
void nn::mii::detail::Ver3StoreDataRaw::GetCreateId(struct nn::mii::detail::Ver3CreateId *) const;
void nn::mii::detail::Ver3StoreDataRaw::GetName(struct nn::mii::Nickname *) const;
void nn::mii::detail::Ver3StoreDataRaw::GetCreatorName(struct nn::mii::Nickname *) const;
int nn::mii::detail::Ver3StoreDataRaw::GetReserved0(void) const;
int nn::mii::detail::Ver3StoreDataRaw::GetReserved1(void) const;
int nn::mii::detail::Ver3StoreDataRaw::GetReserved2(void) const;
int nn::mii::detail::Ver3StoreDataRaw::GetPadding0(void) const;
int nn::mii::detail::Ver3StoreDataRaw::GetPadding1(void) const;
int nn::mii::detail::Ver3StoreDataRaw::GetPadding2(void) const;
int nn::mii::detail::Ver3StoreDataRaw::GetPadding3(void) const;
int nn::mii::detail::Ver3StoreDataRaw::GetPadding4(void) const;
int nn::mii::detail::Ver3StoreDataRaw::GetPadding5(void) const;
int nn::mii::detail::Ver3StoreDataRaw::GetPadding6(void) const;
int nn::mii::detail::Ver3StoreDataRaw::GetPadding7(void) const;
int nn::mii::detail::Ver3StoreDataRaw::GetPadding8(void) const;
int nn::mii::detail::Ver3StoreDataRaw::GetPadding9(void) const;^^ These also reveal that most of our "unknown" fields are just padding for alignment, amazing right?...Except for this mysterious "authorType" that's also present in CFLiCharInfo and in FFL, but nn::mii requires it to be 0 to verify properly so it is truly unused. And by the way, this is the kind of thing I imagine us being able to do together, with our combined skills. Just picture if (a certain Miiverse clone...) allowed custom hair colors and you can still use the same data on Wii U/3DS, verifying correctly on both places. Struct reading suggestion
(Spitballing another concept for doing structs in JS:)
Noooowww.... iiin reality... this would really only help if you wanted to hyper-minimize JS code footprint by only including a few of these (de)serializer methods instead of a library for dealing with structs, and also, REALLY didn't want to rewrite the struct by hand so hard that you only want to import the original C version. I realized only after stumbling upon the excellent struct-fu library that this is not at all necessary though. CreateID/Mii ID handling
Switch fields and colors
Since this is such a long message I'll conclude by saying I am still eager and willing to work with you even if my tone may sound harsh. Thanks. |
|
|
iirc, the MAC address field in Wii Mii data was actually more of a hash or checksum of sorts based on the MAC. after all, MACs are 6 bytes long, and on the Wii, this field was only 4. so the first four bytes of the MAC were combined into 2 and the latter two bytes were copied directly. and on ver3, i'm fairly certain it's just the MAC address in full now that this format has afforded it more space to keep the whole thing. at least... on Wii U and 3DS. as of typing this message, i realize i don't actually know what other platforms do with it. the Nintendo Switch likely just randomizes it (it IS part of the CreateID after all) but does Miitomo pull the MAC address of your phone for this? though this is probably straying away from the original topic - ultimately "MAC address" is still a perfectly fit name for the field in my opinion, on ver3 |
|
I think we should follow the true names as closely as possible (within reason) as part of PretendoNetwork/org-issues#2 , as it would allow easier debugging if something goes wrong since the structure resembles the original |
We already do follow the original names almost everywhere, by coincidence. If you check the originals and the ones here almost all of them line up, with the only differences being very minor ("rotate" vs "rotation") or imo more clear in this implementation ("aspect" vs "height") Of the ones that do differ and do so substantially, I already agreed that they could be better |
this mimics the structure of Kinnays wiki
existing parsers were giving me too much trouble, and bit-buffer was confirmed working before, so just use that under the hood
|
I started this up again since Mii rendering is a hot topic again. With Mii Creator gaining a lot of attention recently and our website devs working on the Mii renderer, I figured now was as good a time as any to try and finish this (plus it's my birthday and this is something light to work on while I celebrate lol) Some key changes since last time:
All in all I think this looks and feels a lot better than it was before. It's still not perfect, ideally this would be made browser compatible as well since I'd like for this to replace MiiJS entirely, and maybe some QoL features like propagating up the fields of child classes to parent ones (so data can be accessed like |
|
Excellent work and commitment here.
Definitely feel your pain here. I had a personal list of struct libraries in JS I found a while ago, if you haven't seen all of these and want to keep trying: natevw/struct-fu#21 (comment) I had to fork struct-fu to get little-endian bitfields to work right. See a sample here. It's pretty small when minified and I got it working in the browser, but I'd understand if it still has flaws or other reasons other reasons to not use the fork (like my JSDoc job).
Nintendo would name it like Official is used in the DB and core is for that unused "hidden" HDB, but also note that in the Wii U DB files they are big-endian making them unreadable by tools without handling it. But, I guess you could fill the rest of the 96 bytes with zeroes and treat core/official like StoreData if you need to...? I also know I aggressively preached accuracy though, so mixed bag there. Just food for thought. |
this is not fully working, but it gets some basics flowing
|
Okay, its not ready yet but I did get the class to parse in a browser with these latest changes and this test file <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="importmap">
{
"imports": {
"bit-buffer": "https://cdn.skypack.dev/bit-buffer",
"buffer": "https://cdn.skypack.dev/buffer"
}
}
</script>
</head>
<body>
<script type="module">
import FFLStoreData from './dist/mii/ffl-store-data.js';
const storeData = FFLStoreData.fromString('AwAAQK/S6FEgm4/62w3zHAOzuI0n2QAA0mJKAG8AbgAAAAAAAAAAAAAAAAAAAF0yAAAPAQJoRBgmNEYUgRIXaI0ADSkDUkhQSgBvAG4AAAAAAAAAAAAAAAAAAAAAAD1z');
console.log(storeData);
</script>
</body>
</html> |
|
@ariankordi By the way, I wanted to discuss with you at some point how possible it might be do Mii rendering on the server, without the need for a Rio game in the background. I'm not sure if that would be a good fit for this repo (unless maybe like a Our biggest use case for Mii rendering is on the server, where we have to render a Mii during account creation and during Mii updates. I know that Mii Creator is getting a lot of attention right now, and it looks nice, but that's all browser based. They've vaguely mentioned some developer API, but that still has a number of issues:
Ideally what we would end up using is something we run ourselves, to prevent issues with downtime and hammering 3rd parties, and allow for future customizations if we choose to add them Is something like your FFL.js port capable of doing something like this? I'm unsure how browser-locked it is. I know sometimes you can get around the browser with other libraries (for example in my side project https://github.com/jonbarrow/trainercards.studio, I draw everything to a standard |
|
Ah yes, rendering. Definitely out of scope for this repo and I hope not to derail the comments here too hard. First, I am really biased against Mii Creator since the author has been a poor communicator/collaborator with me. They've had this push to rewrite FFL.js with another library of theirs, due to "wanting every line of code to be theirs", but I've found their new library to have a bunch of copy-pasted and uncredited code. I am trying to mend things with them, but that's how I feel.
(I know I've been pushy when it comes to licenses before, which is my own fault. If asked, I will happily consider a better license for FFL.js.)
Moving on, it should be "possible" to use FFL.js + Three.js headlessly but haven't tried myself. I noticed that this MiiJS library (totally not like the other mii-js...) has actually tried this in Node. Next topic is the body model. Traditionally, the "Face Library" on consoles only provides the head model. FFL.js has a method to get a head icon, but the body is needed to match official renders. Last comment of mine is that my motivation has been low to work on a lot of this, so the fact you're considering this route is nice to hear. I'd be happy to work on that cleanup in the FFL.js readme, converting to ESM, making those examples, or merging changes if you make any. |
I appreciate the honesty here. I did see Oman sent me a video of things relating to this, which I admittedly have not finished watching (my attention span sucks these days) so I totally get that. I also felt a certain kind of way recently when it was pointed out by Jemma that they have a "import PNID" button which, upon checking Cloudflare, has generated quite a bit of traffic towards us with no heads up that I was made aware of, so maybe I'm a bit biased as well (I know your site does too, but it has far less traffic and you've at least communicated with us before)
Gotcha, that seems to confirm what I also thought
I also agree here. That does seem a little odd. I'm not going to make any accusations of course with regard to the closed source nature of things, but it does seem odd to me some of the decisions they made here and it makes it conflict with projects like ours
It's already under AGPLv3 which is what we default to, so no complaints from us there 👍
I agree with not using 1.0 if possible. Honestly I do wonder if it's worth relying on ThreeJS at all still, and instead just building a custom rendering pipeline. Packages like
That definitely sucks, ouch
We currently use Switch-style renders with shitty settings, so 1:1 is not a MASSIVE concern for me now :P so long as it looks good, it's whatever at this point I just want to make sure we have something
Where is the BFRES on the console? That's in scope for this repo, I'd be willing to put in some leg work here. I'm no 3D model expert though so the process of linking everything together and exporting to different formats may be beyond me, but adding a BFRES parser here is within scope. It also helps that I already worked on a BFRES parser years ago, back when I was making a Super Mario Odyssey level/model viewer EDIT: I found the BFRES, I'll start working on adding the needed file format support here soon
Of course 👍 I did look at some internals of FFL.js and saw some areas I think could use some work, but nothing major rn (mostly just clean up like you said). We've been looking to make a Mii renderer for almost 10 years now, but keep putting it off, it's about time we finally did it lol. Your work as been an incredible help with that
When you say "replace FFL" do you mean the system library, or FFL.js? I only ask because I saw this project recently which looks really cool, even though we likely would never use it (while it looks really cool, when we do things for the Wii U we have to take into account non-modded users because of SSSL, so patches like these typically aren't compatible with us)
Fair enough, and agreed. We don't have to discuss this here moving forward. We do have a repo already for a Mii renderer, back when we were going to try and port Miitomo's renderer. Until shutter said it looked to be a straight FFL port, anyway, so we never did anything with it. The repo is private, and empty, but I might open it and move discussions about rendering there |
|
I talked to Austin (author of Mii Creator) on Thursday and had a great conversation. Without getting into details, we are on better terms now and I don't think he's a bad person - none of us want any drama.
Ah! He's using my API for NNID/PNIDs. I at least made it so PNIDs should cache for a week. But, you can definitely ask him or me (if you can't reach him) to reimplement it himself and add a user agent for rate limiting, or... whatever, depends how you want this managed.
I've tried the THREE.WebGPURenderer once, but it didn't work (can't remember why) and it requires rewriting shaders from GLSL to TSL anyway :( A dependency-less Mii icon renderer using raw WebGPU would be nice to have, but sounds like too much effort to be worth it right now. Three.js is obviously the path of least resistance. So I've thought a bunch of times about a simple Mii icon library in C++ using those that could act as a server and be embeddable, think of using it for something like this. Anyway, if FFL.js + Three.js works for now, that can be a starting point. I just now updated it for WebGL 1.0 support, and simplified the example I showed you by Kestron to give you a cleaner example of making a head-only icon in Node. You should be able to: clone that repo, add
Looks like you found it, but I'll link you to the issue I opened with KillzXGaming about it not opening in Switch Toolbox.
I mean to make an alternative to the FFL PC port Abood made, in favor of a Mii parsing/rendering library that's more modular, flexible, and universal. I'll go into the why and how of this later on, you may get an idea by looking at this repo.
Oh, thanks. That thing is long from production ready, as it causes the Wii U to eventually hang when loading a game. I'm currently in the "hesitate to ask Maschell about it until I eventually forget that I ever wanted to work on it" phase of development.
I keep feeling guilty about notifying everyone in this thread, so just mention me in the place where we can continue. |
Glad to hear 👍
No need for that, the traffic hasn't caused any issues, it's just something that rubbed us the wrong way initially due to the perceived lack of communication
I don't think it has to be "dependency-less", just trying to shoot for something that doesn't require using a ThreeJS version that is going to grow more and more out of date as time goes on. Something simple and embeddable like you showed off here would honestly be ideal, though that can be talked about in the other repo
I did find it yes. I've opened up relevant PRs for this here:
Ideally in the end these should be able to be used together to make a script like: import fs from 'node:fs';
import { CMP } from '@pretendonetwork/nintendo-files/compression';
import { ME01, BFRES } from '@pretendonetwork/nintendo-files';
const decompressed = CMP.fromFile('./main.sgarc.cmp');
const archive = ME01.fromBuffer(decompressed);
const bfresFile = archive.files.find(({ name }) => name === 'g3d/MiiBody/MiiBodyHigh/MiiBodyHigh.bfres');
const bfres = BFRES.fromBuffer(bfres!.data);
const glb = BFRES.exportModelAsGLB('MaleBody');
fs.writeFileSync('MaleBody.glb', glb);
I invited you to https://github.com/PretendoNetwork/mii-renderer earlier today. It's still private since there's nothing there right now (this was originally going to be for our Miitomo-base renderer that we gave up on), but I did open 2 issues about the topic of rendering |
|
Since rendering is going to be done in another repo though, I think I can finally take this out of draft? |
|
Going to also ping @binaryoverload and @mrjvs since the changes made in PretendoNetwork/mii-js#8 seem to be having issues here, as well as @gitlimes to make sure this is still compatible with the website |
|
What do you want me to look at? |
Mostly just the tsup parts and making sure it's browser compatible. I went over the issues I was having in this comment |
simplifies the parsers encode/parse methods by abstracting the field handlers into their own classes
|
Reading your comment, I see a couple of main points:
As for tsup generating one big index.js file. Depending on what your usecases are, that may be what you want. What you can do is make 2 compile targets with tsup. One for node, one for web. That, along with a "browser" exports type in the package.json (or publish it on a Output can't currently be imported with a script tag for the browser because:
The reason this worked for Nuxt in PR PretendoNetwork/mii-js#8 , is because nuxt has a crap ton of compilation steps under the hood that does a best-effort attempt at bundling NodeJS NPM packages for web. Ideally, you'd remove the need for Buffer all together, for example:
If you can't do those, or don't want to put in the effort. You could also half-implement browser support like mii-js did in my PR, it won't work in browsers but bundlers like nuxt and vite will have an easier time with it. About DTS generation being buggy, I'll be honest I have no idea how or why. but using this tsconfig fixed the problems: {
"compilerOptions": {
"strict": true,
"strictPropertyInitialization": false,
"skipLibCheck": true,
"moduleResolution": "bundler",
"baseUrl": "src",
"outDir": "dist",
"target": "es2022",
"paths": {
"@/*": ["./*"]
}
},
"include": ["src"]
}I just updated everything so it makes the most sense to me and now dts compiling works (you do have to remove |
scratch that, I cant even use the fix now. why 🙃 |
|
The issue of the big As for the browser stuff, I honestly had no idea that Nuxt did that. If that's the case then I don't think I'll put too much more effort into making it browser compatible right now. My main use case was our website, which is getting rewritten in Nuxt. I'm open to someone making this truly browser compatible using the methods you mentioned, but so long as it works in Nuxt, I'm happy for now. Thank you for looking into that! |
when lastField is in the instance of the parser, there can be a race condition where a call to both parse and encode, or multiple calls to either, at the same time can set the wrong value in the instance
this commit takes the BinaryParser class from PretendoNetwork/nintendo-file-formats#2 and pulls it into its own library


Resolves #XXX
Changes:
Adds a
MiiGen2class which can decode and encode Mii data used by the Wii U, 3DS and Miitomo. This is meant to replace https://github.com/PretendoNetwork/mii-js eventuallyIntended to be a more-or-less direct translation of the table found at https://www.3dbrew.org/wiki/Mii#Mii_format (which is why the bit handling is done with
field0xXXsections), but in a way that conforms to the requirements of this libraryMarking as draft because more work needs to be done
Required tasks:
MiiGen3class?)Not required, but would really like done before merging, tasks:
UtilclassBitReaderandBitWriterclasses and make something more in line with the other stream classes/handling in this libraryNot required tasks for this PR, but should probably be done at some point:
Some example data/usage for others who want to contribute to this: